package com.home.wechat_

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Box
import androidx.lifecycle.viewmodel.compose.viewModel

import com.home.wechat_.ui.*
import com.home.wechat_.ui.theme.WeTheme

class MainActivity : ComponentActivity() {

    private val mViewModel:WeViewModel by viewModels()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            val mViewModel: WeViewModel = viewModel()

            WeTheme(mViewModel.theme) {
                Box {
                    Home()

                }

            }
        }
    }

    override fun onBackPressed() {
        if(mViewModel.openModule!=null){
            mViewModel.endChat()
        }else{
            super.onBackPressed()
        }

    }


}

